#include <boost/functional/hash.hpp>
using namespace boost;

#define ENTRY

size_t hash_value(int i, int j) {
	size_t seed = 0;
	hash_combine(seed, i);
	hash_combine(seed, j);
	return seed;
}

struct Entry {
	int i, j;
	size_t hash;
	float weight, eps;

	Entry() : i(-1), j(-1), hash(-1), weight(-1.0f), eps(-1.0f) {
	}

	Entry(int _i, int _j, float _weight, float _eps) {
		hash = hash_value(_i, _j);
		i = _i;
		j = _j;
		weight = _weight;
		eps = _eps;
	}

	~Entry() {
	};

	bool operator<(const Entry& rhs) {
		return weight < rhs.weight;
	}

	bool operator==(const Entry& rhs) {
		return hash == rhs.hash;
	}

	std::string to_string() {
		std::stringstream ss;
		ss << "(" << i << "," << j << "," << weight << "," << eps << ")";
		return ss.str();
	}
};

bool operator<(const Entry& lhs, const Entry& rhs) {
	return lhs.weight < rhs.weight;
}

bool sort_by_key(const Entry& lhs, const Entry& rhs) {
	if (lhs.i != rhs.i) return rhs.i < lhs.i;
	else return lhs.j < rhs.j;
}

bool sort_reverse(const Entry& lhs, const Entry& rhs) {
	return lhs.weight > rhs.weight;
}

/*bool operator<(Entry* lhs, Entry* rhs) {
 return (*lhs).weight < (*rhs).weight;
 }*/

bool sort_reverse_ref(Entry* lhs, Entry* rhs) {
	return (*lhs).weight > (*rhs).weight;
}

size_t hash_value(Entry const& e) {
	size_t seed = 0;
	hash_combine(seed, e.i);
	hash_combine(seed, e.j);
	return seed;
}
